<?php

use Illuminate\Database\Seeder;

class BaseReplyTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $spot_ids = \App\Model\Spot::all()->pluck('id')->toArray();

        $user_ids = \App\Model\User::all()->pluck('id')->toArray();

        $faker = app(Faker\Generator::class);

        $base_reply = factory(\App\Model\BaseReply::class)->times(500)
            ->make()
            ->each(function ($base_reply)
                use($spot_ids,$user_ids,$faker)
            {
                $base_reply->spot_id = $faker->randomElement($spot_ids);

                $base_reply->user_id = $faker->randomElement($user_ids);
            });
        \App\Model\BaseReply::insert($base_reply->toArray());
    }
}
